package com.holis.order.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.holis.order.common.PageUtils;
import com.holis.order.common.Query;
import com.holis.order.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.holis.order.entity.HuoliEntity;
import com.holis.order.service.HuoliService;




/**
 *
 *
 * @author lxx
 * @email lixiaoxiao97@qq.com
 * @date 2020-12-04 17:00:30
 */
@RestController
@RequestMapping("order/huoli")
public class HuoliController {
    @Autowired
    private HuoliService huoliService;
    /**
     * 删除：取消我的预约
     * @param params 前端传来此人对应的所有信息
     */
    @RequestMapping("/delete")
    public R delete(@RequestParam  Map<String, Object> params){
        System.out.println(params);
        huoliService.remove(
                new QueryWrapper<HuoliEntity>().allEq(params));

        return R.ok();
    }


    /**
     * 保存: 保存当前预约
     * @param huoli 预约对象
     */
    @RequestMapping("/save")
    public R save(@RequestBody HuoliEntity huoli){
        huoliService.save(huoli);
        return R.ok();
    }
    /**
     * 查询: 查询我的预约
     * @param params 前端传来部门对应的所有预约信息
     */
    @RequestMapping("/selectMyOrderByUserId")
    public R selectMyOrderByUserId(@RequestParam  Map<String, Object> params){
        System.out.println(params);
        List<HuoliEntity> data = huoliService.list(
                new QueryWrapper<HuoliEntity>().eq("user_id", params.get("userId")));
        return R.ok().put("data",data);
    }

    /**
     * 查询: 查询所有预约情况
     * @param params 前端传来此人对应的所有信息
     */
    @RequestMapping("/permissionAll/list")
    public R list(@RequestParam Map<String, Object> params){
        //PageUtils page = huoliService.queryPage(params);
        List<HuoliEntity> list = huoliService.list();
        return R.ok().put("page", list);
    }
    /**
     * 查询：查询根据条件
     * @param params 前端传来此人对应的所有信息
     */
    @RequestMapping("/permissionAll/selectByContdions")
    public R selectByContdions(@RequestParam  Map<String, Object> params){
        System.out.println(params);
        List<HuoliEntity> list = huoliService.list(
                new QueryWrapper<HuoliEntity>().allEq(params));

        return R.ok().put("data",list);
    }
}
